﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sinacor.Infra.UI.Common;
using Sinacor.UI.Bovespa.ResumoFinanceiro.Communication.Bovespa.ManutencaoOrdens.Calendario;
using Sinacor.Infra.UI.Security.Services;

namespace Sinacor.UI.Bovespa.ResumoFinanceiro.Communication
{
    public class Calendario : BaseCommunication
    {
        #region Construtor

        public Calendario(SessionInformation sessionInformation)
            : base(sessionInformation)
        {
        }

        #endregion

        #region Metodos

        public ModelCollection<Model.Calendario> ConsultarCalendario()
        {
            ModelCollection<Model.Calendario> retorno = null;
            ICalendario servico = null;
            try
            {
                using (ServiceInstance<ICalendario> service = new ServiceInstance<ICalendario>())
                {
                    servico = service.TryGetInstance(this.Session);

                    retorno = new Translator.DataContractToModel.Calendario().ToCalendario(
                        servico.ConsultarCalendario());
                }
            }
            catch (Exception ex)
            {
                HandleFault(ex);
            }

            return retorno;
        }

        #endregion
    }
}
